{% load form_helpers %}
{% load helpers %}

<div class="modal fade" tabindex="-1" id="{{ form_name }}_form">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">{{ form_name }}</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal userconfigform" data-config-root="forms.{{ form_as_dialog.form_name }}" action="{{ form_action_url }}" method="post">
                    {% csrf_token %}
                    <h3>
                        {% if settings.DOCS_ROOT %}
                            <div class="pull-right">
                                <button type="button" class="btn btn-link btn-xs" data-toggle="modal" data-target="#docs_modal" title="Help">
                                <i class="mdi mdi-help-circle"></i>
                                </button>
                            </div>
                        {% endif %}
                        {% block title %}{% if editing %}Editing {{ obj_type }} {{ obj }}{% else %}Add a new:{% endif %}{% endblock %}
                    </h3>
                    {% block form %}
                        {% block form_fields %}
                            {% render_form form %}
                        {% endblock %}
                    {% endblock %}
                    <div class="row">
                        <div class="col-md-6 col-md-offset-3 text-right">
                            {% block buttons %}
                                {% if editing %}
                                    <button type="submit" name="_update" class="btn btn-primary">Update</button>
                                {% else %}
                                    <button type="submit" name="_create" class="btn btn-primary">Create</button>
                                {% endif %}
                                <a href="" class="btn btn-default" data-dismiss="modal" aria-label="Close">Cancel</a>
                            {% endblock %}
                        </div>
                    </div>
                </form>
                {% if obj and settings.DOCS_ROOT %}
                    {% include 'inc/modal.html' with name='docs' content=obj|get_docs %}
                {% endif %}
            </div>
        </div>
    </div>
</div>

